package com.ordersys.cloud.service.impl;

import com.ordersys.cloud.entity.Product;
import com.ordersys.cloud.mapper.ProductMapper;
import com.ordersys.cloud.service.ProductService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {
    @Resource
    ProductMapper productMapper;
    @Override
    public int addProduct(Product product) {
        return productMapper.addProduct(product);
    }

    @Override
    public int deleteProduct(Integer id) {
        return productMapper.deleteProduct(id);
    }

    @Override
    public int updateProduct(Product product) {
        return productMapper.updateProduct(product);
    }

    @Override
    public List<Product> getProductAllList() {
        return productMapper.getProductAllList();
    }

    @Override
    public Product getProductById(Integer id) {
        return productMapper.getProductById(id);
    }

    @Override
    public Integer reduceStock(Integer productId, Integer quantity) {
        return productMapper.reduceStock(productId,quantity);
    }
}
